package top.yxqz.session;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/24
 * @package top.yxqz.session
 */
@WebServlet("/demo2")
public class SessionDemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        1.得到Session对象
        HttpSession session = request.getSession();
        String names [] ={"刘备","张飞","关羽"};
        session.setAttribute("names",names);
    }
}
